﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace csharpbasics
{
    class ExtensionsDemo
    {
       public static void demo()
        {
            Money cash1 = new Money();
            cash1.Amount = 40M;
            cash1.AddToAmount(3M);
            Console.WriteLine("cash1.ToString() returns: " + cash1.ToString());
        }
    }

    public class Money
    {
        private decimal amount;
        public decimal Amount
        {
            get
            {
                return amount;
            }
            set
            {
                amount = value;
            }
        }
        public override string ToString()
        {
            return "$" + Amount.ToString();
        }
    }

    public static class MoneyExtension
    {
        public static void AddToAmount(this Money money, decimal amountToAdd)
        {
            money.Amount += amountToAdd;
        }
    }
}
